import { fromJS } from 'immutable';
import * as actionTypes from './actionTypes';

const defaultState = fromJS({
    username: "",
    password: "",
    isLogin: false,
});

export default (state = defaultState, action) => {
    switch(action.type) {
        case actionTypes.CHANGE_USERNAME:
            return state.set("username", action.username);
        case actionTypes.CHANGE_PASSWORD:
            return state.set("password", action.password);
        case actionTypes.LOGIN:
            return state.set("isLogin", action.isLogin);
        case actionTypes.LOGOUT:
            return state.set("isLogin", false);
        default:
            return state;
    }
}
